<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['diy']=$this->plugin_setting('diy');
$return['setting']=$this->plugin_setting('basic');
if($_RQ['op']=='main' || $_RQ['op']=='plant'){
	$return['params']=array('status'=>intval($_RQ['status']));
	$return['list']=array();
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>intval($_RQ['status']));
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_farmer_plant',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['order']=pdo_get('jy_farmer_order',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['order_id']));
			$item['land']=pdo_get('jy_farmer_land',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['land_id']));
			$item['land']['image']=tomedia($item['land']['image']);
			$seed_ids=str_array($item['land']['seed_id']);
			$item['seeds']=array();
			foreach($seed_ids as $id){
				$item['seeds'][]=pdo_get('jy_farmer_seed',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id),array('id','title'));
			}
			$item['isarea']=pdo_getsum('jy_farmer_plant_log',array('uniacid'=>$_SESSION['uniacid'],'plant_id'=>$item['id']),'plantarea');
			$item['lastarea']=$item['plantarea']-$item['isarea'];
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='water'){
	exi('将立即通知管理员浇水');	
}
if($_RQ['op']=='weed'){
	exi('将立即通知管理员除虫');	
}
if($_RQ['op']=='worm'){
	exi('将立即通知管理员除草');	
}
if($_RQ['op']=='shifei'){
	exi('将立即通知管理员施肥');	
}
